package com.training1.core.web.controller;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.training1.core.common.controller.BaseController;
import com.training1.core.common.dao.Page;
import com.training1.core.common.entity.RespJson;
import com.training1.core.common.entity.UserEntity;
import com.training1.core.common.enums.DropDownDto;
import com.training1.core.common.global.signIn.LoginInfoUtil;
import com.training1.core.common.utils.StringUtils;
import com.training1.core.common.utils.framework.RespJsonFactory;
import com.training1.core.entity.HelpEntity;
import com.training1.core.entity.MemberEntity;
import com.training1.core.entity.PaymentEntity;
import com.training1.core.entity.SystemUserEntity;
import com.training1.core.entity.User;
import com.training1.core.modules.service.HelpService;
import com.training1.core.modules.service.PaymentService;

@Controller
@RequestMapping("help")
public class HelpController extends BaseController{
	
	@Resource
	private HelpService helpService;
	
	
	/**
	 * 进入页面
	 * @return
	 */
	@RequestMapping(value={"","/"})
	public String go(){
		return "help/help";
	}
	
	/**
	 * 查询所有数据
	 * @param title
	 * @param keyWord
	 * @param isValid
	 * @param page
	 * @return
	 */
	@RequestMapping(value="list",method=RequestMethod.GET)
	@ResponseBody
	public Page<HelpEntity> list (String title, String keyWord, String isValid, Page<HelpEntity> page){
	
		page.getSearch().put("title", title);
		page.getSearch().put("keyWord", keyWord);
		page.getSearch().put("isValid", isValid);
		
		helpService.findList(page.getSearch());
		
		return page;
		
	}
	/**
	 * 删除
	 * @param help
	 * @return
	 */
	@RequestMapping(value="delete", method={RequestMethod.DELETE})
	@ResponseBody
	public RespJson delByid (@RequestBody HelpEntity help ){
		
		helpService.delete(help.getId());
		return RespJsonFactory.buildSuccess();
		
	}
	
	/**
	 * 保存
	 * @param help
	 * @return
	 */
	@RequestMapping(value="save", method={RequestMethod.POST})
	@ResponseBody
	public RespJson save (@Valid HelpEntity help ){
		
		helpService.save(help);
		
		return RespJsonFactory.buildSuccess();
	}
	
	@RequestMapping(value="edit")
	@ResponseBody
	public HelpEntity edit (String id ){
		
	HelpEntity help	= helpService.get(Integer.valueOf(id));
		
		return help;
	}
	
	
	
}
